package com.sxhuayuan.parking.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/** 代理层级关系表 */
@Entity
@Table(name = "hypk_agent_relation")
public class AgentRelation extends BaseEntity {

	private static final long serialVersionUID = 1866334884903026391L;

	/** 上级节点的id */
	private Agent parent;

	/** 下级节点的id */
	private Agent child;

	/** 以上二者的层级关系，直接父子关系时为1 */
	private Integer level;

	public AgentRelation() {
	}

	public AgentRelation(Agent parent, Agent child, Integer level) {
		this.parent = parent;
		this.child = child;
		this.level = level;
	}

	/**
	 * @return the 上级节点的id
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_id")
	public Agent getParent() {
		return parent;
	}

	/**
	 * @param 上级节点的id
	 *            the parent to set
	 */
	public void setParent(Agent parent) {
		this.parent = parent;
	}

	/**
	 * @return the 下级节点的id
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "child_id")
	public Agent getChild() {
		return child;
	}

	/**
	 * @param 下级节点的id
	 *            the child to set
	 */
	public void setChild(Agent child) {
		this.child = child;
	}

	/**
	 * @return the 以上二者的层级关系，直接父子关系时为1
	 */
	@Column(nullable = false)
	public Integer getLevel() {
		return level;
	}

	/**
	 * @param 以上二者的层级关系
	 *            ，直接父子关系时为1 the level to set
	 */
	public void setLevel(Integer level) {
		this.level = level;
	}

}
